babl-palette: warn when trying to create a palette with > 256 colors
authorEll <ell_se@yahoo.com>
Thu, 14 Jun 2018 06:16:08 +0000 (02:16 -0400)
committerEll <ell_se@yahoo.com>
Thu, 14 Jun 2018 06:22:44 +0000 (02:22 -0400)
... and only use the first 256 colors.

babl/babl-palette.c

index 278c854fe48b48572bd4cb5a604cb156338bf38a..c70d4ed95affb6bea173667e3f7be4e1d0bded6d 100644 (file)
@@ -872,6 +872,16 @@ babl_palette_set_palette (const Babl *babl,
 {
   BablPalette **palptr = babl_get_user_data (babl);
   babl_palette_reset (babl);
+
+  if (count > 256)
+    {
+      babl_log ("attempt to create a palette with %d colors. "
+                "truncating to 256 colors.",
+                count);
+
+      count = 256;
+    }
+
   if (count > 0)
     {
       *palptr = make_pal (format, data, count);